import { useAntd } from '@/components/k-form-design/packages/core/useComponents'
import KFormDesign from '@/components/k-form-design/packages/index.js'
import '@/components/k-form-design/styles/form-design.less'
import 'ant-design-vue/dist/antd.less'
// import { nodeSchema } from '@/components/k-form-design/packages/index.js'
import ZSelectMultiUser from '@/components/zzbiz/ZSelectMultiUser'
import ZUpload from '@/components/zz/ZUpload'
import ZTest from '@/components/zz/ZTest'
import ZAsyncSelect from '@/components/dict/ZAsyncSelect'

// 添加组件
KFormDesign.nodeSchema.addSchemas([
  {
    type: 'ZTest', // 表单类型
    label: '联动测试', // 标题文字
    icon: 'user',
    component: ZTest,
    options: {
      defaultValue: undefined,
      multiple: false,
      disabled: false,
      width: 1000,
      clearable: true,
      placeholder: '请选择',
      showLabel: true,
      orgFields: '',
      destFields: ''
    },
    model: '',
    key: '',
    rules: [
      {
        required: false,
        message: '必填项'
      }
    ]
  },
  {
    type: 'ZSelectMultiUser', // 表单类型
    label: '用户选择', // 标题文字
    icon: 'user',
    component: ZSelectMultiUser,
    options: {
      defaultValue: undefined,
      multiple: false,
      disabled: false,
      width: 1000,
      clearable: true,
      placeholder: '请选择',
      showLabel: true
    },
    model: '',
    key: '',
    rules: [
      {
        required: false,
        message: '必填项'
      }
    ]
  },
  {
    type: 'ZAsyncSelect', // 表单类型
    label: '用户选择(下拉)', // 标题文字
    icon: 'user',
    component: ZAsyncSelect,
    options: {
      defaultValue: undefined,
      multiple: false,
      disabled: false,
      width: 1000,
      clearable: true,
      placeholder: '请选择',
      showLabel: true,
      url: '/user/list',
      optionKey: { label: 'nickname', value: 'username' }
    },
    model: '',
    key: '',
    rules: [
      {
        required: false,
        message: '必填项'
      }
    ]
  },
  {
    type: 'ZUpload', // 表单类型
    label: '文件上传', // 标题文字
    icon: 'upload',
    component: ZUpload,
    options: {
      defaultValue: undefined,
      multiple: false,
      disabled: false,
      width: 1000,
      clearable: true,
      placeholder: '请选择',
      showLabel: true
    },
    model: '',
    key: '',
    rules: [
      {
        required: false,
        message: '必填项'
      }
    ]
  }
])

// 添加分组
KFormDesign.nodeSchema.addSchemaGroup({
  title: '自定义组件',
  list: ['ZSelectMultiUser', 'ZAsyncSelect', 'ZUpload', 'ZTest']
})

export default {
  install(Vue) {
    useAntd(Vue)
    Vue.use(KFormDesign)
  }
}
